package ch.hslu.weather;

import java.io.IOException;
import java.util.List;
import java.util.Locale;

import android.content.Context;
import android.location.Address;
import android.location.Geocoder;

import com.google.android.maps.GeoPoint;

public class MyGeocoder {

	private Geocoder gc;
	
	public MyGeocoder(Context context) {
		gc = new Geocoder(context, Locale.GERMAN);	
	}

	public String getLocation(GeoPoint gp) {
		try {
			List<Address> addresses = gc.getFromLocation(
					gp.getLatitudeE6() / 1E6, gp.getLongitudeE6() / 1E6, 1);
			for (Address address : addresses) {
				String location;
				location = address.getCountryCode() + "-" + address.getPostalCode();
				return location;
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		return "";	
		
	}

}
